- 
                Notifications
    
You must be signed in to change notification settings  - Fork 73
 
Switch to directly invoke python-environments-ext api #849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors Python environment handling to support both the legacy Python extension API and a new Python Environments extension API. The changes enable runtime selection between the two APIs based on a configuration setting and extension availability.
Key Changes:
- Introduced a new 
envExtApi.tsmodule containing the complete Python Environments extension API type definitions - Refactored 
python.tsto conditionally use either the legacy or new environment API viauseEnvExtension()flag - Extracted legacy API implementation into 
legacyPython.tsfor cleaner separation - Updated test suites to accommodate both API paths with new helper utilities
 - Modified debug adapter factory and configuration resolvers to work with the new 
PythonEnvironmenttype 
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description | 
|---|---|
src/extension/envExtApi.ts | 
Added comprehensive API type definitions for the new Python Environments extension (1289 lines) | 
src/extension/common/python.ts | 
Refactored to support dual API paths with conditional logic based on useEnvExtension() | 
src/extension/common/legacyPython.ts | 
Extracted legacy Python extension API implementation from python.ts | 
src/extension/common/utilities.ts | 
Added useEnvExtension() function to determine which API to use at runtime | 
src/extension/debugger/adapter/factory.ts | 
Updated to use new PythonEnvironment type and added version parsing logic | 
src/extension/debugger/configuration/resolvers/base.ts | 
Enhanced to resolve interpreter from program file when appropriate | 
src/extension/debugger/configuration/debugConfigurationService.ts | 
Added interpreter resolution after variable substitution | 
src/extension/common/application/commands/reportIssueCommand.ts | 
Updated to handle both environment API return types | 
src/test/unittest/common/pythonTrue.unit.test.ts | 
New test suite for new environment extension path | 
src/test/unittest/common/pythonFalse.unit.test.ts | 
New test suite for legacy extension path | 
src/test/unittest/common/helpers.ts | 
Added buildPythonEnvironment() test helper function | 
src/test/unittest/adapter/factory.unit.test.ts | 
Updated tests to use new PythonEnvironment type | 
src/test/unittest/configuration/resolvers/launch.unit.test.ts | 
Updated to handle both API return types | 
src/test/unittest/common/application/commands/reportIssueCommand.unit.test.ts | 
Updated mock interpreter structure | 
Comments suppressed due to low confidence (1)
src/test/unittest/common/pythonFalse.unit.test.ts:4
- This expression has no effect.
 
('use strict');
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
switch from using the Python extension apis to get the interpreter to instead using the Python Environments extension APIs (when available) as this will be the new best practice
closes #835